運算子


Posted by mijouhsieh on 2022-03-17

let x = 2
console.log(x)
console.log(x++)
console.log(x)
console.log(++x)
console.log(x)

X++ 和 ++x 不一樣

x++
執行順序是:先列印出 x 的數值後,再進行 x = x + 1 的動作。
++x
執行順序是:先 x = x + 1 ,再列印出 x 的數值。

運算子執行順序
程式碼連結

let x = 2
L2 L3 L4 x++ ++x x += 1 都是賦值完
才L5 印出 x,所以x是賦值完的結果 //3


#assignment operators #x++ #++x #運算子







Related Posts

Day04  增加資料(上) + RecycleView  Adapter

Day04 增加資料(上) + RecycleView Adapter

[Preparation for Interview Basic 1] DOM Element

[Preparation for Interview Basic 1] DOM Element

[ week14 ] 部署 AWS EC2 linux + LAMP Web Server +Sequel Pro +gandi

[ week14 ] 部署 AWS EC2 linux + LAMP Web Server +Sequel Pro +gandi


Comments